package com.share.mybatis.original.mapper;

import com.share.mybatis.original.model.User;
import com.share.mybatis.original.provider.UserProvider;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;

import java.util.List;

/**
 * @author caifan
 * @since 2021/11/3
 * description:
 */
public interface UserMapper {

    @Select({"<script>",
            "select * from user where id in ",
            "<foreach item=\"item\" collection=\"ids\" separator=\",\" open=\"(\" close=\")\">",
            "#{item}",
            "</foreach>",
            "</script>"
    })
    List<User> selectList(@Param("ids") List<Long> ids);

//    @Select("select * from user where id = #{id}")
    @SelectProvider(type = UserProvider.class, method = "selectUserById")
    User selectById(@Param("id") Long id);
}
